<template>
	<view>
<view class="top"><uni-search-bar class="sbg" bgColor="#FFFFFF" @confirm="so" :radius="100"></uni-search-bar>
</view><view class="top-pd"></view>
<view class="bl p10"><text class="b">小贴士</text>：此收藏夹采用本地缓存保存，不会上传至服务器，请放心使用！</view>
<view class="bl p10"><text class="b">提示</text>：换手机或清除缓存，本记录将自动删除！</view>
	<block v-if="id==0">
	
	<view v-for="(item,index2) in nesdata" :key="index2">
<media-item v-if="size==''" :newitem="item"></media-item>
<media-item3 v-else-if="size=='3'" :lc="lc":newitem="item"></media-item3>
<media-item2 v-else :lc="lc":newitem="item"></media-item2>

	<yad mode="feed" v-if="index2%8==3"></yad>
	</view>
	
<view class="b p10 c" v-if="nesdata.length>0">END<br>全部加载完毕</view>
<view class="b p10 c" v-else>No record<br>无记录</view>
	
	
	</block>
	<block v-else>
<view v-for="(item,index2) in nesdata2" :key="index2">
<media-item v-if="size==''" :newitem="item"></media-item>
<media-item3 v-else-if="size=='3'" :lc="lc":newitem="item"></media-item3>
<media-item2 v-else :lc="lc":newitem="item"></media-item2>
<yad mode="feed" v-if="index2%8==3"></yad>
	</view>
<view class="b p10 c" v-if="nesdata2.length>0">END<br>全部加载完毕</view>
<view class="b p10 c" v-else>No record<br>无记录</view>
	</block>
<button type="primary" class="w100" @click="clear()" >还原默认设置</button>
		
<view class="foot-pd"></view>
	<view class="foot"><view class="row"><view class="col b">
	<view class="col_4" @click="restart_size">三<br>切换</view>
	<view :class="id==0?'col_4 red':'col_4'" data-id="0" @click="restart">Fav<br>收藏</view>
	<view :class="id>0?'col_4 red':'col_4'" data-id="1" @click="restart">his<br>历史</view>
	</view></view></view>
	
	</view>
</template>
<script>
	var __self=false
import mediaItem from '@/components/list.vue';
import mediaItem3 from '@/components/list_shop.vue';
import mediaItem2 from '@/components/list_www.vue';
import yad from '@/components/yad.vue'
export default {
components: {
mediaItem,mediaItem2,mediaItem3,yad
},
data() {
return {
id:1,
lc:getApp().globalData.ysv8set.lc,
size:'',
nesdata:[],
nesdata2:[],
}
},onLoad: function (k) {
	__self=this;
     if(k.id==0) this.id=0;
     this.request()
    },
 onShareAppMessage() {
        return {
            title: getApp().globalData.ysv8set.title,
            content: getApp().globalData.ysv8set.description,
            path: 'pages/index/index',
            imageUrl: getApp().globalData.ysv8set.img
        }
},methods: {
so(k) {
    uni.navigateTo({url: '/pageb/s/index?q='+encodeURIComponent(k.value)});
    },
  request() {
let key ="datafav"+this.size+getApp().globalData.ysv8set.apiid
uni.getStorage({
key,
success: res => {
const data = res.data;
if (data) {
this.nesdata=JSON.parse(data)
}else{
this.nesdata=[]	
}
}
});
key ="datalook"+this.size+getApp().globalData.ysv8set.apiid
uni.getStorage({
key,
success: res => {
const data = res.data;
if (data) {
this.nesdata2=JSON.parse(data)
}else{
this.nesdata=[]	
}
}
});
},restart(k){
this.id=k.target.dataset.id;
this.request()
},restart_size(){
uni.showActionSheet({
itemList: ['文章', '本地信息', '店铺'],
success: (e) => {
if(e.tapIndex=='0')
__self.size='';
if(e.tapIndex=='1')
__self.size='2';
if(e.tapIndex=='2')
__self.size='3';
__self.request()
},
});
},clear:function(){
getApp().globalData.ysv8set.localStorage.clear();
//#ifdef H5
location.reload()
//#endif
// #ifdef APP-PLUS
plus.runtime.restart();
//#endif
//#ifdef MP
uni.showModal({
title: 'restart',
content: 'Please restart',
success: function (res) {
uni.reLaunch({
url: '/pages/index/index'
});
},
});
//#endif
			
			
			},
	},
	}
</script>

<style>
</style>
